
<!DOCTYPE html>
<!-- saved from url=(0052)http://49.233.183.177:8080/addressbook/register.html -->
<html lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">


    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>注册</title>

    <link rel="stylesheet" href="/layui/css1/cgj2.css">
    <script src="/layui/layui.js"></script>
</head>

<body class="bg-gradient-primary">

<div class="container">

    <div class="card o-hidden border-0 shadow-lg my-5">
        <div class="card-body p-0">
            <!-- Nested Row within Card Body -->
            <div class="row">
                <div class="col-lg-5 d-none d-lg-block bg-register-image"></div>
                <div class="col-lg-7">
                    <div class="p-5">
                        <div class="text-center">
                            <h1 class="h4 text-gray-900 mb-4">创建账号</h1>
                        </div>
                        <!--添加功能-->
                        <form class="user" action="" method="post" name="MyForm" id="insertRegistForm">
                            <div class="form-group">
                                <input type="text" class="form-control form-control-user" id="regist_account" name="regist_account" placeholder="注册账号,建议为学号">
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control form-control-user" id="regist_name" name="regist_name" placeholder="真实姓名">
                            </div>
                            <div class="form-group">
                                <select  class="form-control " id="regist_gender" name="regist_gender" >
                                    <option selected="selected" value="">请选择性别</option>
                                    <option value="0">男</option>
                                    <option value="1">女</option>
                                </select>
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control form-control-user" id="regist_grade" name="regist_grade" placeholder="年级">
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control form-control-user" id="regist_department" name="regist_department" placeholder="所在院系">
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control form-control-user" id="regist_major" name="regist_major" placeholder="所在专业">
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control form-control-user" id="regist_class" name="regist_class" placeholder="所在班级">
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control form-control-user" id="regist_tel" name="regist_tel" placeholder="注册手机号">
                            </div>
                            <div class="form-group">
                                <input type="text" class="form-control form-control-user" id="regist_email" name="regist_email" placeholder="邮箱">
                            </div>
                            <div class="form-group">
                                <input type="password" class="form-control form-control-user" id="regist_pwd" name="regist_pwd" placeholder="注册密码">
                            </div>
                            <div class="form-group">
                                <input type="password" class="form-control form-control-user" id="regist_pwd_con" name="regist_pwd_con" placeholder="确认密码">
                            </div>
                            <font color="red"></font>
                            <button  class="btn btn-primary btn-user btn-block" lay-submit lay-filter="registFilter" id="registsubmit" onClick="javascript:regist()" >注册</button>
                            <hr>
                        </form>
                        <hr>
                        <div class="text-center">
                            <a class="small" href="login">已有账号? 登录!</a>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script>
    function regist() {
        layui.use(['jquery','form'],function(){
            var $=layui.jquery;
            var form = layui.form;
            let layer = layui.layer;

            //form表单实现添加功能
            form.on('submit(registFilter)', function (data) {

                //提交表单数据

                $.ajax({
                    url: "/user/regist",
                    type: "POST",
                    dataType: "JSON",

                    data: {
                        "user": $("#regist_account").val(),
                        "upassword": $("#regist_pwd").val(),
                        "uname": $("#regist_name").val(),
                        "utel": $("#regist_tel").val(),
                        "uemail": $("#regist_email").val(),
                        "udepartment": $("#regist_department").val(),
                        "umajor": $("#regist_major").val(),
                        "uclass": $("#regist_class").val(),
                        "ugender": $("#regist_gender").val(),
                        "ugrade": $("#regist_grade").val(),
                    },

                    success: function (ret) {
                        if (ret.code == 0) {
                            //关闭对话框
                            //layer.closeAll();
                            //刷新表格数据
                            window.location.href = 'login';
                            layer.msg(ret.msg, {icon: 6});
                        } else {
                            layer.msg(ret.msg, {icon: 5});
                        }
                    }
                });


                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });
        });


    }

</script>
</html>